﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Media3D;

namespace Controls
{
    /// <summary>
    /// Interaction logic for ColorPicker.xaml
    /// </summary>
    public partial class ColorPickerControl : UserControl
    {
        public ColorPickerControl()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(SphereVisual3DSample_Loaded);
        }

        void SphereVisual3DSample_Loaded(object sender, RoutedEventArgs e)
        {
            UpdateMaterial();

            Camera1.Refresh(); // This will measure the models on the scene and reposition the scene camera
        }



        private void UpdateMaterial()
        {
            DiffuseMaterial material;
            ImageBrush imageBrush;

            material = new DiffuseMaterial();

            imageBrush = new ImageBrush();
            imageBrush.ImageSource = new BitmapImage(new Uri(@"ColorPalette.png", UriKind.Relative));

            material.Brush = imageBrush;
            //material.Brush = new SolidColorBrush(Color.FromRgb(123, 56, 32));

            SphereVisual3D1.Material = material;
            SphereVisual3D1.BackMaterial = material;
        }

        private void SphereVisual3D1_GeometryChanged(object sender, EventArgs e)
        {
            if (!this.IsLoaded)
                return;

        }
    }
}
